home *** CD-ROM | disk | FTP | other *** search
/ Video Toaster 4.2 / Video Toaster v4.2.iso / arexx / modeler / shell.lwm < prev    next >
Text File  |  1993-12-13  |  2KB  |  103 lines

  1. /* CMD: Seashell
  2.  *
  3.  * Make a seashell from an outline shape.
  4.  */
  5.  
  6. call addlib "rexxsupport.library", 0, -30, 0
  7. signal on error
  8. signal on syntax
  9. call addlib "rexxmathlib.library", 0, -30, 0
  10. call addlib "LWModelerARexx.port", 0
  11.  
  12.  
  13. sysnam = 'Spin Seashell'
  14. filnam = 'T:shell.state'
  15. version = 'Seashell v1.0'
  16.  
  17. /* Setup state.  Read stored one, if any.
  18.  */
  19. axis = 2
  20. nrep = 4
  21. nsid = 20
  22. off  = 1
  23. scl  = 0.6
  24.  
  25. if (exists(filnam)) then do
  26.     if (~open(state, filnam, 'R')) then break
  27.     if (readln(state) ~= version) then break
  28.     parse value readln(state) with axis nrep nsid off scl .
  29.     call close state
  30. end
  31.  
  32.  
  33. /* Post values for inspection and update.
  34.  */
  35. call req_begin sysnam
  36.  
  37. id_mes  = req_addcontrol("Make a seashell",'T',"from an outline shape.")
  38. id_axis = req_addcontrol("Axis", 'c', 'X Y Z')
  39. id_nrep = req_addcontrol("# of Loops", 'n')
  40. id_nsid = req_addcontrol("Sides per Loop", 'n')
  41. id_off  = req_addcontrol("Shift per Loop", 'n', 1)
  42. id_scl  = req_addcontrol("Scale per Loop", 'n')
  43.  
  44. call req_setval id_axis, axis
  45. call req_setval id_nrep, nrep
  46. call req_setval id_nsid, nsid
  47. call req_setval id_off, off
  48. call req_setval id_scl, scl
  49.  
  50. if (~req_post()) then do
  51.     call req_end
  52.     exit
  53. end
  54.  
  55. axis = req_getval(id_axis)
  56. nrep = req_getval(id_nrep)
  57. nsid = req_getval(id_nsid) % 1
  58. off  = req_getval(id_off)
  59. scl  = req_getval(id_scl)
  60.  
  61. call req_end
  62.  
  63.  
  64. /* Save state now, in case something fails.
  65.  */
  66. if (open(state, filnam, 'W')) then do
  67.     call writeln state, version
  68.     call writeln state, axis nrep nsid off scl
  69.     call close state
  70. end
  71.  
  72.  
  73. /* Perform shell sweep.
  74.  */
  75. n = (nsid * nrep) % 1        /* number of segments in shell */
  76. v0 = subword('0 0', 1, axis - 1)
  77. v1 = subword('0 0', 1, 3 - axis)
  78. rot = 360.0 / nsid
  79. cen = v0 (off * 1.0 / scl) v1
  80. scl = pow(scl, 1.0 / nsid)
  81.  
  82. sc = 1.0
  83. rt = 0.0
  84. call repl_begin 'sweep'
  85. call meter_begin n + 1, sysnam
  86.  
  87. do i = 0 to n
  88.     call repl_step 0, sc, v0 rt v1, cen
  89.     sc = sc * scl
  90.     rt = rt + rot
  91.     call meter_step
  92. end i
  93.  
  94. call meter_end
  95. call repl_end
  96.  
  97. exit
  98.  
  99. syntax:
  100. error:
  101.   call end_all
  102.     t=Notify(1,'!Rexx Script Error','@'ErrorText(rc),'Line 'SIGL)
  103.     exit